package com.ror.java.se.map.hashmap;

import java.util.HashMap;
import java.util.Map;

public class Demo01HashMap {
    public static void main(String[] args) {
        Map<String, String> map = new HashMap<>();

        //put
        map.put("12dora", "9bishi");
        map.put("api", "xrb");
        map.put("lbb", "bls");
        //如果键存在，那么put方法会<u>覆盖</u>原有的键值对，并<u>返回覆盖的值</u>
        System.out.println(map.put("12dora", "12team")); //9bishi
        //如果键不存在，那么put方法返回null
        System.out.println(map.put("kaofish", "lutou")); //null

        //remove方法返回删除的值
        System.out.println(map.remove("12dora")); //12team

        //clear方法清空双列集合
//        map.clear();

        //containsKey
        System.out.println(map.containsKey("api")); //true
        System.out.println(map.containsKey("bpi")); //false

        //containsValue
        System.out.println(map.containsValue("bls")); //true
        System.out.println(map.containsValue("lbb")); //false

        //isEmpty
        System.out.println(map.isEmpty()); //false

        //size
        System.out.println(map.size()); //3

        System.out.println(map);
    }
}
